﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;

namespace Common
{
    /// <summary>
    /// Name/Value对象
    /// </summary>
    /// <typeparam name="TText">Name类型</typeparam>
    /// <typeparam name="TValue">Value类型</typeparam>
    [DebuggerDisplay("Text={Text}      Value={Value}")]
    public class TextValue<TText, TValue>
    {
        /// <summary>
        /// 名称
        /// </summary>
        public TText Text { get; set; }

        /// <summary>
        /// 值
        /// </summary>
        public TValue Value { get; set; }
    }

    /// <summary>
    /// 键值对象
    /// </summary>
    /// <remarks>
    /// <![CDATA[
    /// 此对象只是便于构造Name/Value对象
    /// ]]>
    /// </remarks>
    /// <example>
    /// <code>
    /// <![CDATA[
    /// private void Test()
    /// {
    ///     //实例化一个新的健值对象
    ///     var textValue = TextValue.Instance(1, "Value");
    ///     Console.WriteLine("Text:" + textValue.Text);
    ///     Console.WriteLine("Value:" + textValue.Value);
    /// }
    /// ]]>
    /// </code>
    /// </example>
    public class TextValue
    {
        /// <summary>
        /// 创建一个键值对象
        /// </summary>
        /// <typeparam name="TText">Text的数据类型</typeparam>
        /// <typeparam name="TValue">Value的类型</typeparam>
        /// <param name="text">Text数值</param>
        /// <param name="value">Value值</param>
        /// <example>
        /// <code>
        /// <![CDATA[
        /// private void Test()
        /// {
        ///     //实例化一个新的健值对象
        ///     var textValue = TextValue.Instance(1, "Value");
        ///     Console.WriteLine("Text:" + textValue.Text);
        ///     Console.WriteLine("Value:" + textValue.Value);
        /// }
        /// ]]>
        /// </code>
        /// </example>
        /// <returns>
        /// <![CDATA[
        /// 返回一个新的TextValue<TText, TValue>对象
        /// ]]>
        /// </returns>
        public static TextValue<TText, TValue> Instance<TText, TValue>(TText text, TValue value)
        {
            TextValue<TText, TValue> model = new TextValue<TText, TValue>()
            {
                Text = text,
                Value = value,
            };
            return model;
        }
    }
}
